var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import { defineComponent, ref, computed, onMounted, h, watch, nextTick, onBeforeUnmount, resolveComponent, createElementBlock, openBlock, createElementVNode, createCommentVNode, withModifiers, toDisplayString, normalizeStyle, createVNode, withDirectives, Fragment, renderList, createBlock, vShow, resolveDirective, normalizeClass, withCtx, mergeModels, useModel, normalizeProps, guardReactiveProps, mergeProps, unref, createTextVNode } from "vue";
import { ElIcon, ElSelect, ElOption, ElInput, ElTree, ElMessageBox, ElMessage } from "element-plus";
import { CircleClose, CircleCheck, Plus, Minus, Search } from "@element-plus/icons-vue";
import { defineStore } from "pinia";
import Split from "split.js";
const _sfc_main$5 = defineComponent({
  name: "NodeValue",
  props: {
    data: {
      type: Object,
      required: true
    },
    readonly: {
      type: Boolean,
      required: true
    }
  },
  setup(props, context) {
    const isHasFocus = ref(false);
    const validText = ref("");
    const checkText = ref("");
    const validTypeArr = ["Integer", "BitString", "NumericString", "Ia5string", "OctetString", "String"];
    const otherProps = computed(() => {
      return props.data.bitArray ? props.data.bitArray.map((x) => x ? 1 : 0).join("") : "";
    });
    const formValid = (data) => {
      if (data.isRequired && data.value === "") {
        validText.value = "字段必填";
        return;
      }
      if (data.controlType === "Integer") {
        const { minInclusive, maxInclusive, value } = data;
        if (!minInclusive && !maxInclusive) {
          checkText.value = validText.value = "";
          return;
        }
        if (Number(value) < minInclusive) {
          validText.value = `最小值为${minInclusive}`;
          return;
        }
        if (Number(value) > maxInclusive) {
          validText.value = `最大值为${maxInclusive}`;
          return;
        }
      } else if (data.controlType === "BitString") {
        const { Length } = data;
        checkText.value = `长度为${Length}的二进制数`;
        if (otherProps.value.length !== Length) {
          validText.value = `长度应为${Length}`;
          return;
        }
      }
      validText.value = "";
    };
    const updateEmit = () => {
      if (validText.value === "") {
        context.emit("updateForm", props.data);
      }
    };
    const publicEvent = {
      onfocus: () => {
        isHasFocus.value = true;
      },
      onblur: () => {
        isHasFocus.value = false;
      }
    };
    onMounted(() => {
    });
    const strategy = {
      Integer: (data) => {
        const { value, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          disabled,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: (val) => {
            if (!value) return;
            data.value = parseFloat(val);
            updateEmit();
          },
          ...publicEvent
        });
      },
      Ia5string: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: () => {
            updateEmit();
          },
          ...publicEvent
        });
      },
      String: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          // 保持原有类名 + 组件基础类
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: () => {
            updateEmit();
          },
          ...publicEvent
        });
      },
      OctetString: (data) => {
        const { value, minLength, isReadOnly: disabled } = data;
        return h(ElInput, {
          class: ["int-input", "el-input"],
          modelValue: value,
          // 双向绑定值
          readonly: props.readonly,
          attrs: { minlength: minLength, readonly: props.readonly },
          "onUpdate:modelValue": (val) => {
            data.value = val;
            formValid(data);
          },
          onChange: (val) => {
            const is16Hex = /^[\-A-Fa-f0-9\s]*$/.test(val);
            if (is16Hex) {
              const newValue = value !== "" ? String(value).replace(/\s+/g, "").match(new RegExp("[^\\n]{1,2}", "g")).join(" ") : "";
              data.value = newValue;
              formValid(data);
              updateEmit();
            }
          }
        });
      },
      // NumericString: (data: nodeItem) => {
      //   const { Value: value, MinLength, IsReadOnly: disabled } = data;
      //   return h("el-input", {
      //     class: "int-input",
      //     props: { value, disabled },
      //     attrs: { minlength: MinLength, readonly: props.readonly },
      //     on: {
      //       input: (value: string) => {
      //         const isNumber = /^[\.\-0-9]*$/.test(value);
      //         if (isNumber) {
      //           data.Value = value;
      //           formValid(data);
      //         }
      //       },
      //       ...publicEvent,
      //     },
      //   });
      // },
      // BitString: (data: nodeItem) => {
      //   const { IsReadOnly: disabled } = data;
      //   const { value } = otherProps;
      //   return h("el-input", {
      //     class: "int-input",
      //     props: { otherProps.value.value, disabled },
      //     attrs: { readonly: props.readonly },
      //     on: {
      //       input: (value: string) => {
      //         const isBinary = /^[0|1]*$/.test(value);
      //         if (isBinary) {
      //           data.OtherProps = value;
      //           formValid(data);
      //         }
      //       },
      //       change: (value: string) => {
      //         data.BitArray = value.split("").map(x => !!Number(x));
      //       },
      //       ...publicEvent,
      //     },
      //   });
      // },
      Enum: (data) => {
        const { value, constraint, isReadOnly: disabled } = data;
        const options = [];
        constraint == null ? void 0 : constraint.forEach((optionValue) => {
          options.push({ label: optionValue, value: optionValue });
        });
        return h(
          ElSelect,
          {
            class: "custom-el-select",
            // 添加自定义类名
            modelValue: data.value,
            "onUpdate:modelValue": (val) => {
              data.value = val;
            },
            onChange: () => {
              updateEmit();
            },
            size: "small"
          },
          [
            ...options.map(
              (option) => h(ElOption, {
                key: option.value,
                label: option.label,
                value: option.value
              })
            )
          ]
        );
      },
      // Choice: (data: nodeItem) => {
      //   const { Value: value, Constraint, IsReadOnly: disabled } = data;
      //   const optionsArr = Constraint.map(value => {
      //     if (typeof value === "string") return;
      //     return h("el-option", { props: { label: value.Name, value } });
      //   });
      //   return h(
      //     "el-select",
      //     {
      //       class: "enum-select",
      //       props: { value, valueKey: "Name", placeholder: " ", disabled: disabled || props.readonly },
      //       on: {
      //         input: (value: string) => {
      //           data.Value = value;
      //         },
      //       },
      //     },
      //     [optionsArr],
      //   );
      // },
      Boolean: (data) => {
        const options = [
          { label: "是", value: true },
          { label: "否", value: false }
        ];
        return h(
          ElSelect,
          {
            class: "custom-el-select",
            // 添加自定义类名
            modelValue: data.value,
            "onUpdate:modelValue": (val) => {
              data.value = val;
            },
            onChange: () => {
              updateEmit();
            },
            size: "small"
          },
          [
            ...options.map(
              (option) => h(ElOption, {
                label: option.label,
                value: option.value
              })
            )
          ]
        );
      },
      Sequence: () => {
        return h("div", {}, "");
      },
      SequenceList: (data) => {
        const max = 9999;
        const min = 0;
        const len = data.child && data.child.length;
        const elementName = "成员";
        return h("div", { class: "sequence-list-value" }, [
          h(
            "div",
            {
              class: "btn-icon"
            },
            [
              h(
                ElIcon,
                {
                  class: `el-icon-plus ${len < max ? "" : "gray"}`,
                  onClick: () => {
                    if (len < max) {
                      const addRow = data.elementForm;
                      const count = data.child ? data.child.length + 1 : 1;
                      if (addRow) {
                        addRow.name = `${elementName}(${count})`;
                      }
                      data.child.push(JSON.parse(JSON.stringify(addRow)));
                      updateEmit();
                    }
                  }
                },
                [h(Plus)]
              ),
              h(
                ElIcon,
                {
                  class: `el-icon-minus ${len > min ? "" : "gray"}`,
                  onClick: () => {
                    if (len > min) {
                      data.child.pop();
                      updateEmit();
                    }
                  }
                },
                [h(Minus)]
              )
            ]
          )
          // h("span", { class: "valid-text" }, validText),
        ]);
      },
      // 其他控件类型的渲染逻辑...
      default: (data) => {
        return h("div", {}, `未定义的控件类型: ${data.controlType}`);
      }
    };
    formValid(props.data);
    return () => {
      return h(
        "div",
        {
          class: {
            "node-value": true,
            "node-valid-error": validText.value
          }
        },
        [
          (strategy[props.data.controlType] || strategy.default)(props.data),
          validTypeArr.includes(props.data.controlType) && h("span", { class: "valid-icon" }, [
            [
              validText.value ? h(ElIcon, { color: "red", size: 16 }, [h(CircleClose)]) : isHasFocus.value && !props.readonly && h(ElIcon, { color: "#67c23a", size: 16 }, [h(CircleCheck)])
            ],
            isHasFocus.value && validText.value && h("div", { class: "valid-tips err" }, validText.value),
            !validText.value && !props.readonly && isHasFocus.value && checkText.value && h("div", { class: "valid-tips" }, checkText.value)
          ])
        ]
      );
    };
  }
});
const _export_sfc$1 = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const NodeValue = /* @__PURE__ */ _export_sfc$1(_sfc_main$5, [["__scopeId", "data-v-a8b820df"]]);
const systolicIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<g id="HTSCIT_&#229;&#177;&#149;&#229;&#188;&#128; 2">\r\n<path id="Vector" d="M6.27673 6.28553H17.7233V17.7409H6.27673V6.28553ZM5 5.00881V19H19V5H5V5.00881Z" fill="currentColor"/>\r\n<path id="Vector_2" d="M8 13V11H16V13H8Z" fill="#3a6ef6"/>\r\n</g>\r\n</svg>\r\n';
const expandIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<g id="HTSCIT_&#229;&#177;&#149;&#229;&#188;&#128; 1">\r\n<path id="Vector" d="M6.27673 6.28553H17.7233V17.7409H6.27673V6.28553ZM5 5.00881V19H19V5H5V5.00881Z" fill="currentColor"/>\r\n<path id="Union" fill-rule="evenodd" clip-rule="evenodd" d="M12.5471 8.1925H11.4528V11.4642H8.18115V12.5585H11.4528V15.8302H12.5471V12.5585H15.8189V11.4642H12.5471V8.1925Z" fill="#3a6ef6"/>\r\n</g>\r\n</svg>\r\n';
const toolIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<path d="M13.9498 6C14.8591 6 15.699 6.29966 16.3746 6.80641L15.1183 8.06172L13.892 9.28926L14.7099 10.1078L17.1925 7.62438C17.7138 8.32091 17.997 9.16685 18 10.0369C18.003 10.9069 17.7257 11.7548 17.2093 12.4549C16.6928 13.1551 15.9646 13.6702 15.1325 13.9241C14.3004 14.178 13.4087 14.1571 12.5894 13.8645L8.98345 17.4702C8.82338 17.6359 8.6319 17.7682 8.42019 17.8591C8.20848 17.9501 7.98077 17.9979 7.75036 17.9999C7.51995 18.0019 7.29145 17.958 7.07819 17.8708C6.86493 17.7835 6.67118 17.6546 6.50825 17.4917C6.34532 17.3288 6.21647 17.135 6.12922 16.9217C6.04197 16.7084 5.99806 16.4799 6.00007 16.2495C6.00207 16.019 6.04994 15.7913 6.14088 15.5796C6.23183 15.3678 6.36402 15.1763 6.52976 15.0163L10.1351 11.41C9.9171 10.7988 9.84914 10.1442 9.93696 9.5013C10.0248 8.85838 10.2658 8.24598 10.6397 7.71569C11.0137 7.1854 11.5095 6.75274 12.0856 6.45416C12.6616 6.15558 13.301 5.99982 13.9498 6Z" fill="currentColor"/>\r\n</svg>\r\n';
const _sfc_main$4 = defineComponent({
  name: "NodeItem",
  components: {
    NodeValue
  },
  props: {
    data: {
      type: Object,
      required: true
    },
    w: {
      type: Number,
      required: true
    },
    readonly: {
      type: Boolean,
      required: true
    }
  },
  setup(props, { emit }) {
    const isExpand = ref(props.data.isExpand !== false);
    const isChildren = computed(() => {
      return props.data.child && props.data.child.length > 0;
    });
    const handleUpdate = (data) => {
      emit("updateForm", data);
    };
    return {
      isExpand,
      isChildren,
      handleUpdate,
      systolicIcon,
      expandIcon,
      toolIcon
    };
  }
});
const _hoisted_1$2$1 = { class: "node-view" };
const _hoisted_2$2$1 = { class: "node-item" };
const _hoisted_3$1$1 = { class: "left-item" };
const _hoisted_4$2 = { class: "icon-view" };
const _hoisted_5$1 = ["innerHTML"];
const _hoisted_6$1 = ["innerHTML"];
const _hoisted_7$1 = { class: "label-view" };
const _hoisted_8$1 = {
  key: 0,
  class: "node-children"
};
const _hoisted_9$1 = {
  key: 1,
  class: "node-children"
};
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_NodeValue = resolveComponent("NodeValue");
  const _component_NodeItem = resolveComponent("NodeItem", true);
  return openBlock(), createElementBlock("div", _hoisted_1$2$1, [
    createElementVNode("div", _hoisted_2$2$1, [
      createElementVNode("div", _hoisted_3$1$1, [
        createElementVNode("div", _hoisted_4$2, [
          _ctx.isChildren ? (openBlock(), createElementBlock("span", {
            key: 0,
            class: "ex-icon force-svg-16",
            innerHTML: _ctx.isExpand ? _ctx.systolicIcon : _ctx.expandIcon,
            onClick: _cache[0] || (_cache[0] = withModifiers(($event) => _ctx.isExpand = !_ctx.isExpand, ["stop"]))
          }, null, 8, _hoisted_5$1)) : (openBlock(), createElementBlock("span", {
            key: 1,
            class: "icon",
            innerHTML: _ctx.toolIcon
          }, null, 8, _hoisted_6$1))
        ]),
        createElementVNode("div", _hoisted_7$1, toDisplayString(_ctx.data.name), 1)
      ]),
      createElementVNode("div", {
        class: "right-item",
        style: normalizeStyle({ width: _ctx.w ? `${_ctx.w / 2}px` : "" })
      }, [
        createVNode(_component_NodeValue, {
          data: _ctx.data,
          readonly: _ctx.readonly,
          onUpdateForm: _ctx.handleUpdate
        }, null, 8, ["data", "readonly", "onUpdateForm"])
      ], 4)
    ]),
    _ctx.isChildren ? (openBlock(), createElementBlock("div", _hoisted_8$1, [
      withDirectives(createElementVNode("div", null, [
        (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data.child, (x, i) => {
          return openBlock(), createBlock(_component_NodeItem, {
            key: i,
            data: x,
            w: _ctx.w,
            readonly: _ctx.readonly,
            onUpdateForm: _ctx.handleUpdate
          }, null, 8, ["data", "w", "readonly", "onUpdateForm"]);
        }), 128))
      ], 512), [
        [vShow, _ctx.isExpand]
      ])
    ])) : createCommentVNode("", true),
    _ctx.data.controlType === "Choice" && _ctx.data.value ? (openBlock(), createElementBlock("div", _hoisted_9$1, [
      (openBlock(true), createElementBlock(Fragment, null, renderList([_ctx.data.value], (x, i) => {
        return openBlock(), createBlock(_component_NodeItem, {
          key: i,
          data: x,
          w: _ctx.w,
          readonly: _ctx.readonly,
          onUpdateForm: _ctx.handleUpdate
        }, null, 8, ["data", "w", "readonly", "onUpdateForm"]);
      }), 128))
    ])) : createCommentVNode("", true)
  ]);
}
const NodeItem = /* @__PURE__ */ _export_sfc$1(_sfc_main$4, [["render", _sfc_render$1], ["__scopeId", "data-v-49690e0a"]]);
const _sfc_main$3$1 = defineComponent({
  name: "NodeTree",
  components: {
    NodeItem
  },
  props: {
    data: {
      type: Array,
      required: true
    },
    isHideHeader: {
      type: Boolean,
      default: false
    },
    readonly: {
      type: Boolean,
      default: false
    },
    isLoading: {
      type: Boolean,
      default: false
    }
  },
  setup(props, { emit }) {
    const treeTbodyW = ref(0);
    const treeTbody = ref(null);
    const scrollbar = ref(null);
    watch(
      () => props.data.length,
      () => {
        nextTick(() => {
          updateTreeTbodyWidth();
        });
      }
    );
    const updateTreeTbodyWidth = () => {
      if (treeTbody.value) {
        treeTbodyW.value = treeTbody.value.offsetWidth;
      }
    };
    const handleResize = () => {
      updateTreeTbodyWidth();
    };
    onMounted(() => {
      window.addEventListener("resize", handleResize);
    });
    onBeforeUnmount(() => {
      window.removeEventListener("resize", handleResize);
    });
    const handleUpdate = (data) => {
      emit("updateForm", data);
    };
    return {
      treeTbodyW,
      treeTbody,
      scrollbar,
      handleUpdate
    };
  }
});
const _hoisted_1$1$1 = { class: "node-content" };
const _hoisted_2$1$1 = { class: "tree-thead" };
const _hoisted_3$2 = {
  ref: "treeTbody",
  class: "tree-tbody"
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_NodeItem = resolveComponent("NodeItem");
  const _component_el_scrollbar = resolveComponent("el-scrollbar");
  const _component_Empty = resolveComponent("Empty");
  const _directive_loading = resolveDirective("loading");
  return withDirectives((openBlock(), createElementBlock("div", _hoisted_1$1$1, [
    withDirectives(createElementVNode("div", _hoisted_2$1$1, [
      _cache[0] || (_cache[0] = createElementVNode("div", { class: "item" }, "名称", -1)),
      createElementVNode("div", {
        class: "item",
        style: normalizeStyle({ width: _ctx.treeTbodyW ? `${_ctx.treeTbodyW / 2}px` : "" })
      }, "值", 4)
    ], 512), [
      [vShow, !_ctx.isHideHeader && _ctx.data.length]
    ]),
    withDirectives(createVNode(_component_el_scrollbar, {
      ref: "scrollbar",
      class: normalizeClass(["tree-scrollbar", _ctx.data.length ? "" : "fill-scroll"])
    }, {
      default: withCtx(() => [
        createElementVNode("div", _hoisted_3$2, [
          (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (x, i) => {
            return openBlock(), createBlock(_component_NodeItem, {
              key: i,
              data: x,
              w: _ctx.treeTbodyW,
              readonly: _ctx.readonly,
              onUpdateForm: _ctx.handleUpdate
            }, null, 8, ["data", "w", "readonly", "onUpdateForm"]);
          }), 128))
        ], 512)
      ]),
      _: 1
    }, 8, ["class"]), [
      [vShow, _ctx.data.length]
    ]),
    withDirectives(createVNode(_component_Empty, { class: "null-box" }, null, 512), [
      [vShow, !_ctx.data.length && !_ctx.isLoading]
    ])
  ])), [
    [_directive_loading, _ctx.isLoading]
  ]);
}
const index = /* @__PURE__ */ _export_sfc$1(_sfc_main$3$1, [["render", _sfc_render], ["__scopeId", "data-v-c3f35861"]]);
const _hoisted_1$4 = { class: "pagination" };
const _hoisted_2$3 = { class: "total" };
const _sfc_main$2$1 = /* @__PURE__ */ defineComponent({
  __name: "Pagination",
  props: /* @__PURE__ */ mergeModels({
    total: { default: 0 }
  }, {
    "page": { default: 1 },
    "pageModifiers": {},
    "size": { default: 30 },
    "sizeModifiers": {}
  }),
  emits: ["update:page", "update:size"],
  setup(__props) {
    const page = useModel(__props, "page");
    const size = useModel(__props, "size");
    return (_ctx, _cache) => {
      const _component_el_pagination = resolveComponent("el-pagination");
      return openBlock(), createElementBlock("div", _hoisted_1$4, [
        createElementVNode("div", _hoisted_2$3, "共 " + toDisplayString(_ctx.total) + " 条记录 第" + toDisplayString(page.value) + "/" + toDisplayString(Math.ceil(_ctx.total / size.value) || 1) + "页", 1),
        createVNode(_component_el_pagination, {
          "current-page": page.value,
          "onUpdate:currentPage": _cache[0] || (_cache[0] = ($event) => page.value = $event),
          "page-size": size.value,
          "onUpdate:pageSize": _cache[1] || (_cache[1] = ($event) => size.value = $event),
          layout: "sizes, prev, pager, next, jumper",
          "page-sizes": [30, 100, 200, 300],
          total: _ctx.total,
          background: "",
          size: "small"
        }, null, 8, ["current-page", "page-size", "total"])
      ]);
    };
  }
});
const Pagination = /* @__PURE__ */ _export_sfc$1(_sfc_main$2$1, [["__scopeId", "data-v-667ba724"]]);
const _sfc_main$1$1 = /* @__PURE__ */ defineComponent({
  __name: "Empty",
  props: {
    props: { default: () => ({}) }
  },
  setup(__props) {
    return (_ctx, _cache) => {
      const _component_el_empty = resolveComponent("el-empty");
      return openBlock(), createBlock(_component_el_empty, normalizeProps(guardReactiveProps(_ctx.props)), null, 16);
    };
  }
});
const Empty = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-d68485ba"]]);
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
  ...{
    name: "TooltipBox"
  },
  __name: "TooltipBox",
  props: {
    content: { default: "" },
    required: { type: Boolean, default: false },
    tooltipAttrs: { default: () => ({
      placement: "top-start",
      openDelay: 0
    }) }
  },
  setup(__props) {
    const isShowTip = ref(false);
    const checkShowTip = (event) => {
      const target = event.currentTarget;
      isShowTip.value = target.clientWidth < target.scrollWidth;
    };
    return (_ctx, _cache) => {
      const _component_el_tooltip = resolveComponent("el-tooltip");
      return openBlock(), createBlock(_component_el_tooltip, mergeProps({
        effect: "dark",
        content: _ctx.content,
        disabled: !isShowTip.value,
        tabindex: -1
      }, _ctx.tooltipAttrs), {
        default: withCtx(() => [
          createElementVNode("div", {
            class: normalizeClass(["name one-line", { required: _ctx.required }]),
            onMouseenter: checkShowTip
          }, toDisplayString(_ctx.content), 35)
        ]),
        _: 1
      }, 16, ["content", "disabled"]);
    };
  }
});
const TooltipBox = /* @__PURE__ */ _export_sfc$1(_sfc_main$6, [["__scopeId", "data-v-7bfdccdf"]]);
const SEND_CREATE_TASK_CMD_KEY = "send-create-task-cmd";
const GET_CREATE_TASK_DATA_KEY = "get-create-task-data";
const useCreateTaskStore = defineStore("createTaskInjection", () => {
  const sendCreateTaskCmd = ref(null);
  const setInjections = (injections) => {
    if (injections.sendCreateTaskCmd) {
      sendCreateTaskCmd.value = injections.sendCreateTaskCmd;
    }
  };
  return { sendCreateTaskCmd, setInjections };
});
function createCommand(moduleId, fixedParams) {
  return async function(data, params, config2 = {}) {
    const createTaskStore = useCreateTaskStore();
    const sendCreateTaskCmd = createTaskStore.sendCreateTaskCmd;
    if (!sendCreateTaskCmd) {
      throw new Error("sendCreateTaskCmd 未在 Pinia 中初始化，请检查插件根组件是否正常挂载");
    }
    const commandPayload = {
      moduleId,
      fixedParams,
      data,
      params: { ...fixedParams, ...params },
      config: config2
    };
    const result = await sendCreateTaskCmd("execute", commandPayload);
    return result;
  };
}
const createTaskModuleId = "CreateTaskForm";
const routerLinkTestView = createCommand(createTaskModuleId, { commandName: "RouterLink" });
const getSolutionsByCondition = createCommand(createTaskModuleId, { commandName: "GetSolutionsByCondition" });
const startCreateTask = createCommand(createTaskModuleId, { commandName: "StartCreateTask" });
const cancelCreateTask = createCommand(createTaskModuleId, { commandName: "CancelCreateTask" });
const completeCreateTask = createCommand(createTaskModuleId, { commandName: "CompleteCreateTask" });
const getTestCaseTree = createCommand(createTaskModuleId, { command: "GetTestCaseTree" });
const setSelectCases = createCommand(createTaskModuleId, { command: "SetSelectCases" });
const getTestCaseConfig = createCommand(createTaskModuleId, { command: "GetTestCaseConfig" });
const updateTestCaseConfig = createCommand(createTaskModuleId, {
  command: "UpdateTestCaseConfig"
});
const _hoisted_1$3 = { class: "solution-list" };
const _hoisted_2$2 = { class: "list-ct" };
const _hoisted_3$1 = { class: "search-box" };
const _hoisted_4$1 = {
  key: 0,
  class: "list"
};
const _hoisted_5 = ["onClick"];
const _hoisted_6 = { class: "name-warp" };
const _hoisted_7 = { class: "name" };
const _hoisted_8 = { class: "version" };
const _hoisted_9 = { class: "desc" };
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  __name: "SolutionList",
  emits: ["choose"],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    const isLoading = ref(false);
    const query = ref({ pageIndex: 1, pageSize: 30, solutionName: "" });
    const tableData = ref([
      {
        describe: "测向",
        id: "0c344cf9-8e15-4dc7-93a3-cd0640f5f651",
        name: "无线电监测测向",
        version: "1.0",
        assembly: "Solution.OATS",
        configs: []
      }
    ]);
    const total = ref(0);
    onMounted(() => {
      console.log("挂载函数执行");
      getList();
    });
    const getList = async () => {
      const test = await getSolutionsByCondition(query.value);
      console.log("test", test);
      const {
        data: { list, total_Count }
      } = await getSolutionsByCondition(query.value);
      console.log("测试方案集合", list);
      isLoading.value = false;
      tableData.value = list || [];
      total.value = total_Count || 0;
    };
    const handleChoose = (row) => {
      emit("choose", row);
    };
    return (_ctx, _cache) => {
      const _component_el_icon = resolveComponent("el-icon");
      const _component_el_input = resolveComponent("el-input");
      const _component_el_scrollbar = resolveComponent("el-scrollbar");
      const _directive_loading = resolveDirective("loading");
      return openBlock(), createElementBlock("div", _hoisted_1$3, [
        createElementVNode("div", _hoisted_2$2, [
          createElementVNode("div", _hoisted_3$1, [
            createVNode(_component_el_input, {
              modelValue: query.value.solutionName,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => query.value.solutionName = $event),
              modelModifiers: { trim: true },
              placeholder: "请输入方案名称"
            }, {
              suffix: withCtx(() => [
                createElementVNode("div", {
                  class: "icon",
                  onClick: getList
                }, [
                  createVNode(_component_el_icon, null, {
                    default: withCtx(() => [
                      createVNode(unref(Search))
                    ]),
                    _: 1
                  })
                ])
              ]),
              _: 1
            }, 8, ["modelValue"])
          ]),
          withDirectives((openBlock(), createBlock(_component_el_scrollbar, { class: "scroll-bar" }, {
            default: withCtx(() => [
              tableData.value.length || isLoading.value ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
                (openBlock(true), createElementBlock(Fragment, null, renderList(tableData.value, (item) => {
                  return openBlock(), createElementBlock("div", {
                    class: "item",
                    key: item.id,
                    onClick: ($event) => handleChoose(item)
                  }, [
                    createElementVNode("div", _hoisted_6, [
                      createElementVNode("div", _hoisted_7, toDisplayString(item.name), 1),
                      createElementVNode("div", _hoisted_8, toDisplayString(item.version), 1)
                    ]),
                    createElementVNode("div", _hoisted_9, toDisplayString(item.describe), 1)
                  ], 8, _hoisted_5);
                }), 128))
              ])) : unref(Empty) ? (openBlock(), createBlock(unref(Empty), { key: 1 })) : createCommentVNode("", true)
            ]),
            _: 1
          })), [
            [_directive_loading, isLoading.value]
          ])
        ]),
        unref(Pagination) ? (openBlock(), createBlock(unref(Pagination), {
          key: 0,
          page: query.value.pageIndex,
          "onUpdate:page": _cache[1] || (_cache[1] = ($event) => query.value.pageIndex = $event),
          size: query.value.pageSize,
          "onUpdate:size": _cache[2] || (_cache[2] = ($event) => query.value.pageSize = $event),
          total: total.value
        }, null, 8, ["page", "size", "total"])) : createCommentVNode("", true)
      ]);
    };
  }
});
const _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const Solution = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-0338f869"]]);
function isEmail(value) {
  return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
    value
  );
}
function isMobile(value, type = 2) {
  switch (type) {
    case 1:
      return /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-7|9])|(?:5[0-3|5-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1|8|9]))\d{8}$/.test(value);
    case 2:
      return /^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(value);
    case 3:
      return /^(?:(?:\+|00)86)?1\d{10}$/.test(value);
  }
}
function isPhone(value) {
  return /^\d{3}-\d{8}$|^\d{4}-\d{7,8}$/.test(value);
}
function isZipCode(value) {
  const reg = /^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/;
  return reg.test(value);
}
const _hoisted_1$2 = { class: "task-form" };
const _hoisted_2$1 = { class: "btn-box" };
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  __name: "TaskForm",
  props: {
    solution: { default: () => ({}) }
  },
  emits: ["prev", "next"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const formView = ref();
    const config2 = ref([
      { label: "基础信息", type: "title" },
      { label: "任务名称", prop: "name", required: true },
      { label: "申请单位信息", type: "title" },
      { label: "单位名称", prop: "applicantCompany" },
      { label: "通信地址", prop: "address" },
      { label: "邮政编码", prop: "zipCode", rules: validatorFn([isZipCode], "邮政编码") },
      { label: "电话", prop: "tel", rules: validatorFn([isMobile, isPhone], "电话") },
      { label: "经办人", prop: "person" },
      { label: "电子信箱", prop: "email", rules: validatorFn([isEmail], "电子信箱") },
      { label: "设备信息", type: "title" },
      { label: "设备名称", prop: "dutName" },
      { label: "设备型号", prop: "dutMode" },
      { label: "序列号", prop: "deviceNum" },
      { label: "生产单位", prop: "manufacturer" },
      { label: "检测类型", prop: "testType" },
      { label: "委托单位", prop: "client" }
      // { label: "测试条件", type: "title" },
      // { label: "温度", prop: "temperature", inputType: "number", unit: "℃" },
      // { label: "湿度", prop: "humidity", inputType: "number", unit: "%" }
    ]);
    const formData = ref({});
    const btnLoading = ref(false);
    function validatorFn(condition, label) {
      return [
        {
          validator(_rule, value, callback) {
            if (value === "" || condition.find((it) => it(value))) {
              callback();
            } else {
              callback(new Error(`请输入正确的${label}`));
            }
          },
          trigger: "blur"
        }
      ];
    }
    const handleNext = async () => {
      var _a;
      try {
        const value = await ((_a = formView.value) == null ? void 0 : _a.submit());
        console.log("值：", value);
        btnLoading.value = true;
        const { id, name, version } = props.solution;
        const { data } = await startCreateTask({
          ...value,
          id,
          solutionName: name,
          solutonVersion: version
        });
        btnLoading.value = false;
        if (!data) {
          return;
        }
        emit("next", data);
      } catch (err) {
        console.log(err);
        btnLoading.value = false;
      }
    };
    return (_ctx, _cache) => {
      var _a;
      const _component_XcForm = resolveComponent("XcForm");
      const _component_el_button = resolveComponent("el-button");
      return openBlock(), createElementBlock("div", _hoisted_1$2, [
        createVNode(_component_XcForm, {
          class: "form-view",
          ref_key: "formView",
          ref: formView,
          config: config2.value,
          values: formData.value,
          colProps: 4,
          labelPosition: "right"
        }, null, 8, ["config", "values"]),
        createElementVNode("div", _hoisted_2$1, [
          createVNode(_component_el_button, {
            type: "primary",
            size: "large",
            onClick: _cache[0] || (_cache[0] = ($event) => emit("prev"))
          }, {
            default: withCtx(() => [..._cache[1] || (_cache[1] = [
              createTextVNode("上一步", -1)
            ])]),
            _: 1
          }),
          createVNode(_component_el_button, {
            type: "primary",
            size: "large",
            disabled: !((_a = formView.value) == null ? void 0 : _a.data.name),
            loading: btnLoading.value,
            onClick: handleNext
          }, {
            default: withCtx(() => [..._cache[2] || (_cache[2] = [
              createTextVNode("下一步", -1)
            ])]),
            _: 1
          }, 8, ["disabled", "loading"])
        ])
      ]);
    };
  }
});
const TaskForm = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-e45b0ce9"]]);
const folderIcon = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<path id="Vector" d="M11.4102 3.5952C11.649 3.9348 11.3646 4.35 10.9488 4.35H0.6C0.44087 4.35 0.288258 4.28679 0.175736 4.17426C0.0632141 4.06174 0 3.90913 0 3.75V2.652C0 1.188 1.188 0 2.652 0H4.044C5.022 0 5.328 0.318 5.718 0.84L6.558 1.956C6.744 2.202 6.768 2.232 7.116 2.232H8.79C9.873 2.232 10.8312 2.7702 11.4102 3.5952ZM11.9898 5.8482C11.9893 5.68938 11.9259 5.53723 11.8134 5.4251C11.701 5.31297 11.5486 5.25 11.3898 5.25H0.6C0.44087 5.25 0.288258 5.31321 0.175736 5.42574C0.0632141 5.53826 0 5.69087 0 5.85V8.79C0 10.56 1.44 12 3.21 12H8.79C10.56 12 12 10.56 12 8.79L11.9898 5.8482ZM7.458 8.85H4.458C4.206 8.85 4.008 8.652 4.008 8.4C4.008 8.154 4.206 7.95 4.458 7.95H7.458C7.57735 7.95 7.69181 7.99741 7.7762 8.0818C7.86059 8.16619 7.908 8.28065 7.908 8.4C7.908 8.51935 7.86059 8.63381 7.7762 8.7182C7.69181 8.80259 7.57735 8.85 7.458 8.85Z" fill="#E3AE5D"/>\r\n</svg>\r\n';
const nodeIcon = '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">\r\n<path id="Vector" d="M10.8837 8.51163V3.48837C11.5479 3.2093 12 2.55628 12 1.81395C12 0.814884 11.1851 0 10.186 0C9.4493 0 8.7907 0.452093 8.51163 1.11628H3.48837C3.2093 0.452093 2.55628 0 1.81395 0C0.814884 0 0 0.814884 0 1.81395C0 2.5507 0.452093 3.2093 1.11628 3.48837V8.51163C0.452093 8.7907 0 9.44372 0 10.186C0 11.1851 0.814884 12 1.81395 12C2.5507 12 3.2093 11.5479 3.48837 10.8837H8.51163C8.7907 11.5479 9.44372 12 10.186 12C11.1851 12 12 11.1851 12 10.186C12 9.4493 11.5479 8.7907 10.8837 8.51163ZM9.99628 8.38326C9.93488 8.38884 9.87907 8.4 9.81767 8.41116C9.66698 8.43907 9.52186 8.4893 9.38233 8.56186C9.34884 8.5786 9.31535 8.59535 9.28186 8.61767C9.00279 8.77395 8.77395 9.00279 8.61767 9.28186C8.59535 9.31535 8.5786 9.34884 8.56186 9.38233C8.4893 9.52186 8.43907 9.66698 8.41116 9.81767C8.4 9.87907 8.38884 9.93488 8.38326 9.99628C8.37768 10.013 8.37768 10.0298 8.37768 10.0465H3.62233C3.61085 9.91013 3.58465 9.7754 3.54419 9.64465C3.53302 9.6 3.51628 9.54977 3.49395 9.50512C3.47721 9.46605 3.46047 9.42698 3.43814 9.38233C3.4214 9.34884 3.40465 9.31535 3.38233 9.28186C3.22605 9.00279 2.99721 8.77395 2.71814 8.61767C2.68465 8.59535 2.65116 8.5786 2.61767 8.56186C2.57302 8.53954 2.53395 8.52279 2.49488 8.50605C2.45023 8.48372 2.4 8.46698 2.35535 8.45581C2.22461 8.41535 2.08987 8.38915 1.95349 8.37768V3.62233C2.0986 3.61116 2.23256 3.58326 2.36651 3.5386C2.41674 3.52744 2.47256 3.50512 2.52279 3.48279C2.5507 3.47163 2.58419 3.45488 2.61767 3.43814C2.65116 3.4214 2.68465 3.40465 2.71814 3.38233C2.99721 3.22605 3.22605 2.99721 3.38233 2.71814C3.40465 2.68465 3.4214 2.65116 3.43814 2.61767C3.45488 2.58419 3.47163 2.5507 3.48279 2.52279C3.50512 2.47256 3.52744 2.41674 3.5386 2.36651C3.58326 2.23256 3.61116 2.0986 3.62233 1.95349H8.37768C8.38884 2.10419 8.41674 2.24372 8.46698 2.38326C8.47814 2.42791 8.49488 2.47814 8.51721 2.52279C8.52837 2.55628 8.54512 2.58419 8.56186 2.61767C8.5786 2.65116 8.59535 2.68465 8.61767 2.71814C8.77395 2.99721 9.00279 3.22605 9.28186 3.38233C9.31535 3.40465 9.34884 3.4214 9.38233 3.43814C9.41581 3.45488 9.44372 3.47163 9.47721 3.48279C9.52186 3.50512 9.57209 3.52186 9.61674 3.53302C9.75628 3.58326 9.89581 3.61116 10.0465 3.62233V8.37768C10.0298 8.37768 10.013 8.37768 9.99628 8.38326Z" fill="#37BA8B"/>\r\n</svg>\r\n';
const _hoisted_1$1 = {
  class: "tree-form",
  ref: "split"
};
const _hoisted_2 = { class: "custom-tree-node" };
const _hoisted_3 = ["innerHTML"];
const _hoisted_4 = { class: "btn-box" };
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "TreeForm",
  props: {
    taskInfo: { default: () => ({}) }
  },
  emits: ["prev", "reset"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const leftView = ref();
    const rightView = ref();
    const treeRef = ref();
    const nodeTreeRef = ref();
    const loadTree = ref(false);
    const treeData = ref([]);
    const currentItem = ref({});
    const defaultCheckKeys = ref([]);
    const nodeData = ref([]);
    const configLoading = ref(false);
    const btnLoading = ref(false);
    const oldDataString = ref("[]");
    onMounted(async () => {
      initSplit();
      getTreeData();
    });
    const initSplit = () => {
      const options = [{ el: [leftView.value, rightView.value], direction: "horizontal", sizes: [20, 80] }];
      options.forEach((x) => {
        Split(x.el, {
          snapOffset: 0,
          gutterSize: 10,
          sizes: x.sizes,
          direction: x.direction,
          onDragEnd: () => {
            console.log("拖动结束");
          }
        });
      });
    };
    const getTreeData = async (isUpdate = false) => {
      var _a;
      !isUpdate && (loadTree.value = true);
      const { data } = await getTestCaseTree({}, { taskId: props.taskInfo.id });
      treeData.value = data ? [{ ...data, children: handleData(data) }] : [];
      if (!isUpdate) {
        !currentItem.value.id && (currentItem.value = ((_a = treeData.value) == null ? void 0 : _a[0]) || []);
        getNodeData();
        defaultCheckKeys.value = treeData.value.map((it) => it.id);
        loadTree.value = false;
      }
      console.log("树结构数据", treeData.value);
    };
    const getNodeData = async () => {
      configLoading.value = true;
      const { data } = await getTestCaseConfig({ caseId: currentItem.value.id || "" }, { taskId: props.taskInfo.id });
      configLoading.value = false;
      nodeData.value = data || [];
      oldDataString.value = JSON.stringify(nodeData.value);
    };
    const handleData = (data) => {
      const caseList = [...data.testCases || [], ...data.childCase || []].map((it) => {
        return { ...it, isCase: true };
      });
      let children = [...data.childTree || [], ...caseList];
      if (children.length) {
        children = children.map((item) => {
          return { ...item, children: handleData(item) };
        });
      }
      return children;
    };
    const handleNodeClick = async (row) => {
      var _a, _b;
      console.log(row);
      if (row.id === currentItem.value.id) return;
      (_a = treeRef.value) == null ? void 0 : _a.setCurrentKey(currentItem.value.id);
      const hasErr = updataScrollChange();
      if (hasErr) {
        await ElMessageBox.confirm("当前表单输入不规范，切换将失去当前修改，确认放弃本次修改?", "提示", { type: "warning" });
      } else if (oldDataString.value !== JSON.stringify(nodeData.value)) {
        updateTestCaseConfig({ caseId: currentItem.value.id || "", config: nodeData.value }, { taskId: props.taskInfo.id });
        ElMessage.success("参数更新成功");
      }
      (_b = treeRef.value) == null ? void 0 : _b.setCurrentKey(row.id);
      currentItem.value = row;
      getNodeData();
    };
    const updataScrollChange = () => {
      var _a, _b;
      const errorEle = (_a = nodeTreeRef.value) == null ? void 0 : _a.$el.querySelector(".node-valid-error");
      const heightTop = errorEle && errorEle.offsetTop;
      const scrollEle = (_b = nodeTreeRef.value) == null ? void 0 : _b.scrollbar;
      scrollEle.setScrollTop(heightTop || 0);
      return !!errorEle;
    };
    const handleFinish = async () => {
      var _a, _b;
      try {
        btnLoading.value = true;
        const hasErr = updataScrollChange();
        if (hasErr) {
          ElMessage.error("您有表单内容没有按规范填写");
          return;
        }
        let chooseId = ((_a = treeRef.value) == null ? void 0 : _a.getCheckedKeys()) || [];
        const halfChooseId = ((_b = treeRef.value) == null ? void 0 : _b.getHalfCheckedKeys()) || [];
        const testCaseIds = [...halfChooseId, ...chooseId];
        if (!testCaseIds.length) {
          ElMessage.error("请选择测试用例");
          return;
        }
        const taskId = String(props.taskInfo.id || "");
        if (oldDataString.value !== JSON.stringify(nodeData.value)) {
          await updateTestCaseConfig({ caseId: currentItem.value.id || "", config: nodeData.value }, { taskId });
          ElMessage.success("参数更新成功");
        }
        await setSelectCases({ testCaseIds }, { taskId });
        await completeCreateTask(void 0, { taskId });
        ElMessage.success("任务创建成功");
        emit("reset");
        await routerLinkTestView("/testView?taskId=" + taskId);
      } finally {
        btnLoading.value = false;
      }
    };
    return (_ctx, _cache) => {
      const _component_el_scrollbar = resolveComponent("el-scrollbar");
      const _component_el_button = resolveComponent("el-button");
      const _directive_loading = resolveDirective("loading");
      return openBlock(), createElementBlock("div", _hoisted_1$1, [
        createElementVNode("div", {
          class: "left-view",
          ref_key: "leftView",
          ref: leftView
        }, [
          withDirectives((openBlock(), createBlock(_component_el_scrollbar, { ref: "treeScroll" }, {
            default: withCtx(() => [
              createVNode(unref(ElTree), {
                ref_key: "treeRef",
                ref: treeRef,
                data: treeData.value,
                "highlight-current": true,
                props: { label: "name", children: "testCases" },
                "node-key": "id",
                "expand-on-click-node": false,
                "check-on-click-leaf": false,
                "default-expand-all": "",
                "default-checked-keys": defaultCheckKeys.value,
                "show-checkbox": "",
                "icon-class": "el-icon-arrow-right",
                "current-node-key": currentItem.value.id,
                onNodeClick: handleNodeClick
              }, {
                default: withCtx(({ data }) => [
                  createElementVNode("div", _hoisted_2, [
                    createElementVNode("span", {
                      innerHTML: data.testCases ? unref(folderIcon) : unref(nodeIcon)
                    }, null, 8, _hoisted_3),
                    createVNode(unref(TooltipBox), {
                      content: data.name,
                      tooltipAttrs: { placement: "right", offset: 38 }
                    }, null, 8, ["content"])
                  ])
                ]),
                _: 1
              }, 8, ["data", "default-checked-keys", "current-node-key"])
            ]),
            _: 1
          })), [
            [_directive_loading, loadTree.value]
          ])
        ], 512),
        createElementVNode("div", {
          class: "right-view",
          ref_key: "rightView",
          ref: rightView
        }, [
          createVNode(unref(index), {
            isLoading: configLoading.value,
            class: "node-tree",
            ref_key: "nodeTreeRef",
            ref: nodeTreeRef,
            data: nodeData.value
          }, null, 8, ["isLoading", "data"]),
          createElementVNode("div", _hoisted_4, [
            createVNode(_component_el_button, {
              type: "primary",
              size: "large",
              onClick: _cache[0] || (_cache[0] = ($event) => emit("prev"))
            }, {
              default: withCtx(() => [..._cache[1] || (_cache[1] = [
                createTextVNode("上一步", -1)
              ])]),
              _: 1
            }),
            createVNode(_component_el_button, {
              type: "primary",
              size: "large",
              loading: btnLoading.value,
              onClick: handleFinish
            }, {
              default: withCtx(() => [..._cache[2] || (_cache[2] = [
                createTextVNode("完 成", -1)
              ])]),
              _: 1
            }, 8, ["loading"])
          ])
        ], 512)
      ], 512);
    };
  }
});
const TreeForm = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-241d5df1"]]);
const _hoisted_1 = { class: "add-task" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: "CreateTask",
    components: { Solution, TaskForm, TreeForm }
  },
  __name: "index",
  setup(__props, { expose: __expose }) {
    const step = ref(1);
    const solution = ref({});
    const taskInfo = ref({});
    onBeforeUnmount(() => {
      cancelTask();
    });
    watch(
      () => step.value,
      () => {
        console.log("step", step);
      }
    );
    const cancelTask = async () => {
      var _a;
      const taskId = ((_a = taskInfo.value) == null ? void 0 : _a.id) || "";
      if (taskId) {
        await cancelCreateTask(void 0, { taskId });
      }
    };
    const handleChoose = (row) => {
      solution.value = row;
      step.value = 2;
    };
    const handleNext = (data) => {
      taskInfo.value = data;
      step.value = step.value + 1;
    };
    const handlePrev = () => {
      step.value = step.value - 1;
    };
    const backStep = () => {
      cancelTask();
      handlePrev();
    };
    const handleReset = () => {
      step.value = 1;
      taskInfo.value = {};
      solution.value = {};
    };
    const dataEvent = (data) => {
      console.log("子组件收到数据了", data);
    };
    __expose({
      dataEvent
    });
    const createTaskStore = useCreateTaskStore();
    console.log("存储后 Pinia 中的值111：", createTaskStore.sendCreateTaskCmd);
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        withDirectives(createVNode(Solution, { onChoose: handleChoose }, null, 512), [
          [vShow, step.value === 1]
        ]),
        withDirectives(createVNode(TaskForm, {
          solution: solution.value,
          onNext: handleNext,
          onPrev: handlePrev
        }, null, 8, ["solution"]), [
          [vShow, step.value === 2]
        ]),
        step.value === 3 ? (openBlock(), createBlock(TreeForm, {
          key: 0,
          taskInfo: taskInfo.value,
          onPrev: backStep,
          onReset: handleReset
        }, null, 8, ["taskInfo"])) : createCommentVNode("", true)
      ]);
    };
  }
});
const CreateTaskForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-54497cfc"]]);
const config = {
  moudleType: "CreateTaskForm",
  name: "创建任务模块",
  version: "1.0.0",
  description: "创建任务"
};
class CreateTaskModule {
  constructor(sendCmd, initialData = {}) {
    __publicField(this, "config", config);
    __publicField(this, "_eventData");
    __publicField(this, "sendCmd");
    this._eventData = ref(initialData);
    this.sendCmd = sendCmd;
  }
  sendCommand(cmd, cmdParams) {
    console.log("发送指令：", cmd, cmdParams);
    return this.sendCmd(this.config.moudleType, cmd, cmdParams);
  }
  install(app) {
    app.component("CreateTaskForm", CreateTaskForm);
    app.provide(GET_CREATE_TASK_DATA_KEY, () => this.eventData);
    app.provide(SEND_CREATE_TASK_CMD_KEY, (cmd, cmdParams) => {
      console.log("插件内部转发指令：", cmd, cmdParams);
      return this.sendCommand(cmd, cmdParams);
    });
  }
  get eventData() {
    return this._eventData;
  }
  dataEvent(data) {
    Object.assign(this._eventData, data);
  }
  async startup() {
    const taskStore = useCreateTaskStore();
    if (!taskStore.sendCreateTaskCmd) {
      console.log("Pinia 中未存储 sendCreateTaskCmd,进行存储");
      taskStore.setInjections({
        sendCreateTaskCmd: (cmd, cmdParams) => this.sendCommand(cmd, cmdParams)
      });
    }
    console.log("插件根组件获取到 sendCreateTaskCmd,初始化成功", taskStore.sendCreateTaskCmd);
    console.log("存储后 Pinia 中的值：", taskStore.sendCreateTaskCmd);
    console.log("创建任务模块初始化完成");
  }
}
const createCreateTaskModule = (sendCmd, initialData) => {
  return new CreateTaskModule(sendCmd, initialData);
};
export {
  CreateTaskForm,
  createCreateTaskModule
};
